package com.baizhi.buff;

import java.io.*;

/**
 * 用缓冲字节流拷贝视频并测试效率
 *
 * 复制内容
 *  文件流，   文件流块读写    字节缓冲流     字节缓冲流读写
 *
 *  文件流< 字节缓冲流 <  文件流块读写 < 字节缓冲流读写
 *
 */
public class BufferCopy1 {
    public static void main(String[] args) throws IOException {

        long start = System.currentTimeMillis();

        FileInputStream fis = new FileInputStream("G:/java笔记/day16/5月9日pm.mp4");
        BufferedInputStream bis = new BufferedInputStream(fis);


        FileOutputStream fos = new FileOutputStream("./javase_io/视频.mp4");
        BufferedOutputStream bos = new BufferedOutputStream(fos);

        byte[] bytes = new byte[1024 * 10 * 8];
        
        int d;
        while((d = bis.read(bytes))!=-1){
            bos.write(bytes,0,d);
        }

        bos.close();
        bis.close();

        long end = System.currentTimeMillis();

        System.out.println("复制完毕，耗时："+(end-start)+ "ms");
    }
}
